<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>企业信息列表页</title>
<link href="${pageContext.request.contextPath }/js/kindeditor-4.1.10/themes/default/default.css" type="text/css" rel="stylesheet">
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<link id="easyuiTheme" rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/default.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"	type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/outOfBounds.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/js/common.js" type="text/javascript"></script>
</head>
</head>
<body>
	<table class="easyui-datagrid" id="companyList" title="公司网站群列表" 
       data-options="singleSelect:false,collapsible:true,pagination:true,url:'${pageContext.request.contextPath}/admin/company/companylist.do',method:'post',pageSize:30,toolbar:toolbar">
	<thead>
        <tr>
        	<th data-options="field:'ck',checkbox:true"></th>
            <th data-options="field:'name',width:200,align:'center'">公司名称</th>
            <th data-options="field:'about',width:300,align:'center'">简介</th>
            <th data-options="field:'grouptel',width:200,align:'center'">电话</th>
            <th data-options="field:'groupservicetel',width:200,align:'center'">集团客服电话</th>
            <th data-options="field:'advertiseemail',width:200,align:'center'">俱乐部邮箱</th>
            <th data-options="field:'copyright',width:200,align:'center'">版权</th>
            <th data-options="field:'record',width:300,align:'center'">备案信息</th>
            <th data-options="field:'ext1',width:300,align:'center'">微信公众号</th>
            <th data-options="field:'ext2',width:300,align:'center'">俱乐部网址</th>
            <th data-options="field:'ext3',width:300,align:'center'">传媒网址</th>
            <th data-options="field:'ext4',width:300,align:'center'">集团网址</th>
            <th data-options="field:'ext5',width:300,align:'center'">集团总部</th>
        </tr>
    </thead>
</table>
<div id="companyAddWindow" class="easyui-window" title="添加" data-options="modal:true,closed:true,iconCls:'icon-save',href:'${pageContext.request.contextPath }/admin/company/company_add.do'" style="width:1000px;height:500px;padding:10px;"></div>
<div id="companyEditWindow" class="easyui-window" title="编辑" data-options="modal:true,closed:true,iconCls:'icon-save',href:'${pageContext.request.contextPath }/admin/company/company_edit.do'" style="width:1000px;height:500px;padding:10px;"></div>
<script type="text/javascript">
//获取选中的ID值
function getSelectionsIds(){
	var siteList = $("#companyList");
	var sels = siteList.datagrid("getSelections");
	var ids = [];
	for(var i in sels){
		ids.push(sels[i].id);
	}
	ids = ids.join(",");
	return ids;
}

//删除功能
function doDelete(){
	//获取选中的id
	var ids = getSelectionsIds();
	$.messager.confirm('确认','确定删除ID为 '+ids+' 的公司信息吗？',function(r){
	    if (r){
	    	var params = {"ids":ids};
        	$.post("${pageContext.request.contextPath }/admin/company/deletecompany.do",params, function(data){
    			if(data.status == 200){
    				 $.messager.alert('提示', data.data, 'info', function() {
							$("#companyList").datagrid("reload");
					});
    			}else{
    				if(data.status == 200){
       				 $.messager.alert('提示', data.data, 'info', function() {
   							$("#companyList").datagrid("reload");
   					});
    				}
    			}
    		},'json');
	    }
	});
}


//添加功能
function doAdd(){
	//打开弹窗
	$("#companyAddWindow").window( ).window("open");		
}

//编辑功能
function doEdit(){
	var ids = getSelectionsIds();

	if(ids.length == 0){
		$.messager.alert('提示','必须选择一个网站才能编辑!');
		return ;
	}
	if(ids.indexOf(',') > 0){
		$.messager.alert('提示','只能选择一个网站!');
		return ;
	}
	
	$("#companyEditWindow").window({
		onLoad :function(){
			//回显基础数据
			//获取选中行的数据
			var data = $("#companyList").datagrid("getSelected");
			
			$("#companyEditForm").form("load",data);
		}
	}).window("open");
	
}

var toolbar = [{
    text:'添加',
    iconCls:'icon-add',
    handler:doAdd
},{
    text:'编辑',
    iconCls:'icon-edit',
    handler: doEdit
},{
    text:'删除',
    iconCls:'icon-cancel',
    handler: doDelete
}];
</script>
</body>
</html>